//
//  CoachsBookTextViewCell.m
//  CoachsBook
//
//  Created by huiyong li on 2022/8/20.
//

#import "CoachsBookTextViewCell.h"
#import "Long_TextView.h"

@interface CoachsBookTextViewCell ()
@property (nonatomic, strong) UILabel *titleLabel;
@property (strong, nonatomic) Long_TextView *remarkTextView;
@property (nonatomic, strong) UIView *lineView;
@end

@implementation CoachsBookTextViewCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier])
    {
        [self setViews];
        self.contentView.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setViews
{
    self.lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, 0)];
    self.lineView.backgroundColor = rgba(245, 245, 250, 1);

    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(self.lineView.frame)+10, 150, 30)];
    self.titleLabel.font = [UIFont systemFontOfSize:16];
    self.titleLabel.textColor = rgba(51, 51, 51, 1);

    
    WS(weakSelf)
    self.remarkTextView = [[Long_TextView alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(self.titleLabel.frame)+10, APPwidth-30, 200) letfEdge:5 topEdgw:10 hintText:@"描述详情" maxLength:200];
    [self.remarkTextView setBackgroundColor:rgba(245, 245, 245, 1)];
    [self.remarkTextView.textView setFont:[UIFont systemFontOfSize:14]];
    [self.remarkTextView.hintLable setFont:[UIFont systemFontOfSize:14]];
    self.remarkTextView.hintLable.textColor =rgba(153, 153, 153, 1);
    [self.remarkTextView.textLenthLable setFont:[UIFont systemFontOfSize:14]];
    self.remarkTextView.textLenthLable.textColor = rgba(153, 153, 153, 1);
    self.remarkTextView.radius = 4;
    self.remarkTextView.Long_TextViewBlock = ^(NSString * _Nonnull textViewText) {
        if (weakSelf.CertificationTextViewBlock) {
            weakSelf.CertificationTextViewBlock(textViewText);
        }
    };
    [self.contentView addSubview:self.lineView];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.remarkTextView];
}

-(void)cellFillWithModel:(CoachsBookInputModel *)model
{
    if (model.showTopline) {
        self.lineView.frame = CGRectMake(0, 0, APPwidth, 10);
    }
    self.titleLabel.text = model.title;
    self.remarkTextView.textView.text = model.content;
    self.remarkTextView.hintLable.text = model.prompt;
    if (![LongHelper isBlankString:model.content]) {
        self.remarkTextView.isShowhintText = NO;
    }
}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
